/* 
 * GrayRabbit Cms基于J2EE架构内容管理系统
 * Copyright © GrayRabbit Co., Ltd. All rights reserved.
 * Department：运营部
 * 更多信息，请visit:
 * http://code.google.com/p/gray-rabbit-cms/
 */
package org.grayrabbit.cms.dao.content; 

import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.grayrabbit.cms.entity.Category;
import org.grayrabbit.cms.entity.Content;
import org.grayrabbit.cms.vo.content.ContentBean;
import org.grayrabbit.dao.GenericDao;
import org.grayrabbit.dao.util.Page;
import org.grayrabbit.dao.util.QueryCondition;

/**
 * <b>Content</b>的DAO接口

 * @version 1.0,创建时间:2011-05-16 14:40:11 
 */
public interface ContentDao extends GenericDao<Content, String>{
	
	/**
	 * 根据bean组装查询条件
	 */
	public QueryCondition assembly(ContentBean bean);
	/**
	 * 根据bean组装统计查询条件
	 */
	public QueryCondition assemblyCount(ContentBean bean);
	public int count(ContentBean bean);
	public int countAllByPublish(ContentBean bean);
	/**
	 * 根据bean组装查询条件(名称参数)
	 */
	public QueryCondition assermblyNameQuery(ContentBean bean);
	
	/**
	 * 根据bean组装统计查询条件(名称参数)
	 */
	public QueryCondition assemblyNameQueryCount(ContentBean bean);
	/**
	 * 填充分页组件
	 * @param page
	 * @param bean
	 */
	public List<Content> findByPage(Page<Content> page, ContentBean bean);
	/**
	 * 获取非属性对象的条件
	 * @param page
	 * @param bean
	 * @return
	 */
	public List<Content> findByPageNotIn(Page<Content> page, ContentBean bean);
	/**
	 * 根据BEAN组装非属性的查询条件
	 * @param bean
	 * @return
	 */
	public QueryCondition assermblyNotInQuery(ContentBean bean);
	/**
	 * 根据栏目id查询
	 * @param catId
	 * @return
	 */
	public List<Content>findByCatId(String catId);
	
	public List<Content>findByTopicId(String topicId);
	
	public List<Content> findAll(ContentBean contentBean);
	
	public int countNotIn(ContentBean bean);
	
	public List<Content> ftlFindAll(String[] docIds, String flag,
			String[] catIds, String[] contentTypes, String begintime,
			String endTime, String[] keywords, String condition,
			String orderBy, long[] limit, boolean pagination, long pageSize,
			long crrunetPage);
	
	public List<Content> darkblueFindAll(String[] siteId, String[] docIds, String flag, String[] catIds, String[] topicIds,
			String[] contentTypes, String begintime, String endTime,
			String[] keywords, String condition, String orderBy, long[] limit,
			boolean pagination, long pageSize, long crrunetPage,
			boolean showLike, boolean rondom, long maxPageCount, String articleType);
	
	public List<Content> ftlFindAllTopic(String[] docIds, String flag,
			String topicId, String[] keywords, String[] excludeIds,
			String[] contentTypes, String begintime, String endTime,
			String condition, String orderBy, long[] limit, boolean pagination,
			long pageSize, long crrunetPage, boolean showLike, boolean rondom,
			long maxPageCount);
	public int findTotalNum(QueryCondition qc);
	public List<Content> findPublish(ContentBean contentBean,int currentContentIndex, int max);
	public List<Content> findPublish(ContentBean contentBean);
	public List<Content> findPublish(ContentBean contentBean,int pageSize);
	/**
	 * 检查文章标题是否已经存在
	 * @param role
	 * @return
	 */
	public Boolean checkNameUnique(String contentTitle);
	/**
	 * 搜索查询税务
	 * @param keywords
	 * @return
	 */
	public int searchCount(ContentBean bean);
	/**
	 * 搜索查询税务筹划
	 * @param keywords
	 * @return
	 */
	public int searchPlanCount(ContentBean bean);
	public List<Content> searchPage(Page<Content> page,ContentBean bean);
	public List<Content> searchPlanPage(Page<Content> page,ContentBean bean);
	/**
	 * 根据栏目id查询文章-多个栏目id
	 * @param catList
	 * @return
	 */
	public List<Content>findByCats(List<String>catList);
	public List<Content>  findByIds(String[] ids);
	/**
	 * @param docIds
	 *            文档Id
	 * @param flag
	 *            内容自定义属性
	 * @param catIds
	 *            栏目ID
	 * @param contentTypes
	 * @param begintime
	 *            指定发布的开始时间
	 * @param endTime
	 *            指定发布的结束时间
	 * @param keywords
	 *            内容的关键字 或者的关系
	 * @param condition
	 *            自定义查询条件
	 * @return
	 */
	public int ftlFindAllCount(String[] docIds, String flag, String[] catIds, String[] contentTypes, String begintime, String endTime, String[] keywords, String condition);

	public int ftlFindAllTopicCount(String[] docIds, String flag, String topicId, String[] keywords, String[] excludeIds, String[] contentTypes, String begintime, String endTime, String condition,
			boolean showLike);

	/**
	 * 根据文章id获得栏目名称
	 * @param contentId
	 * @return
	 */
	public String getCatName(String contentId);
	
	/**
	 * 查找类似的文章(ZSK)
	 * @param contentId
	 * @param count
	 * @return
	 */
	public List<Content> getSameZskContent(String contentId,int count);
	
	public List<Content> getSiteSameContent(Content c,int count,List<Category> catList);
	
	public List<Content> ftlFindTopPosts(int num);
	
	/**
	 * 查找发布的文章
	 * @param offset
	 * @param maxSize
	 * @param catIds 文章所属的栏目，Null全部栏目
	 * @param noCatIds 不包括的文章栏目,Null不过滤
	 * @return
	 */
	public List<Content> ListPublishContent(int offset,int maxSize,String[] catIds,String[] noCatIds);
	
	public int countPublishContent(String[] catIds,String[] noCatIds);
	public Content findDocBycatIds(Set<String> set, String string);
	public List<Content> finddocsByCatIds(Set<String> set, int num);
	public int findByTitleAndCreatedTime(String contentTitle,
			Date createTime, String categoryId);
	public List<String> findContentIdsBySiteId(List<String> list,int currentContentIndex, int max);
	public Iterator<Content> findContentBySiteIds(List<String> siteIds,int currentContentIndex);
	public Iterator<Content> findMoreContentIdsBySiteIds(List<String> siteIds,int currentContentIndex);
	
}